import { commonService } from '~/config/server'
import { NetService } from '~/utils/net.service'
import { Inject, Debounce } from "~/core/decorator";
import { Service } from '~/core/service'

export class ReminderMessageService extends Service {
  @Inject(NetService)
  private netService: NetService

  /**
   * 获取未读消息数列表
   */
  public getUnReadCount(messageType?) {
    return this.netService.send({
      server: commonService.reminderMessageController.getUnReadCount,
      data: {
        messageType
      }
    })
  }

  /**
   * 批量删除消息
   */
  @Debounce()
  public batchDelete(ids) {
    return this.netService.send({
      server: commonService.reminderMessageController.batchDelete,
      data: {
        ids
      }
    })
  }

  /**
   * 获取消息列表
   * @param state 消息类型,分为已读、未读和全部
   */
  public getReminderMessages(state, messageType, page) {
    return this.netService.send({
      server: commonService.reminderMessageController.getReminderMessages,
      data: {
        state,
        messageType
      },
      page
    })
  }

  /**
   * 设置消息状态为已读
   * @param id
   */
  @Debounce()
  public setMessageRead(id) {
    return this.netService.send({
      server: commonService.reminderMessageController.setSelectedMessageRead,
      data: {
        id
      }
    })
  }
  public getWorkbenchReminder() {
    return this.netService.send({
      server: commonService.reminderMessageController.getWorkbenchReminder,
    })
  }
}

